package org.fatmansoft.teach.controllers;

import org.fatmansoft.teach.payload.request.DataRequest;
import org.fatmansoft.teach.payload.response.DataResponse;
import org.fatmansoft.teach.service.AbsenceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/absenceRecord")
public class AbsenceRecordController {
    @Autowired
    AbsenceRecordService absenceRecordService;
    @PostMapping("/getRecords")
    public DataResponse getRecords(@Valid @RequestBody DataRequest dataRequest) {
        return absenceRecordService.getAbsenceRecordListByPersonNum(dataRequest);
    }

    @PostMapping("/editRecord")
    public DataResponse editRecords(@Valid @RequestBody DataRequest dataRequest) {
        return absenceRecordService.editRecordById(dataRequest);
    }

    @PostMapping("/deleteRecord")
    public DataResponse deleteRecords(@Valid @RequestBody DataRequest dataRequest) {
        return absenceRecordService.deleteRecordById(dataRequest);
    }
    @PostMapping("/createRecord")
    public DataResponse createRecords(@Valid @RequestBody DataRequest dataRequest) {
        return absenceRecordService.createRecord(dataRequest);
    }
}
